<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<c:set var="ctxPath" value="${pageContext.request.contextPath}"
	scope="application" />
<!DOCTYPE  html >
<html>
<head>
   <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <meta name="description" content="">
  <meta name="author" content="ThemeBucket">
  <link rel="shortcut icon" href="#" type="../image/png">
<title>订单列表信息</title>
<link rel="stylesheet" href="${ctxPath}/static/css/bootstrap.min.css" />
<script src="${ctxPath}/static/js/jquery.js"></script>
<script type="text/javascript" src="${ctxPath}/static/js/bootstrap-paginator.js"></script>
</head>
<body>
<h2>订单信息列表</h2>
	<!-- 搜索区域 -->
	 <div class="row" style="padding-bottom: 20px;margin-top:20px;">
	 <!-- 搜索框的长度为该行的3/4 -->
	 <div>
	  <div class="input-group" style="width:18%;float: right;padding-right: 20px">
	  	<input id="searchString" type="text" style="height:35px;width:100%;" class="form-control" placeholder="请输入订单号">
		 <span class="input-group-btn">
		<button type="button" class="btn btn-info" onclick="search()" onkeypress="Enter()">
	   	<span class="glyphicon glyphicon-search" aria-hidden="true">搜索</span>
	   </button>
	  </span>
	 </div>
	 </div>
	 </div>
	<table class="table table-striped table-bordered table-hover table-checkable" style="height:400px;"
		id="datatable_ajax">
		<thead>
			<tr>
				<th>订单ID</th>
				<th>下单时间</th>
				<th>下单客户</th>
				<th>收货电话</th>
				<th>收货地址</th>
				<th>状态</th>
				<th>总金额</th>
				<th>查看订单详情</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${indents }" var="indent">
				<tr>
					<td>${indent.indentId }</td>
					<td><fmt:formatDate value="${indent.beginTime }"
							pattern="yyyy-MM-dd hh:mm:ss" /></td>
					<td>${indent.name }</td>
					<td>${indent.takeGoodsTel }</td>
					<td>${indent.baseAddress}${indent.detailAddress}</td>
					<td><c:choose>
							<c:when test="${indent.status==15 }">已完成</c:when>
						</c:choose></td>
					<td>${indent.fullPay }</td>
					<td><a class="btn btn-info"
						onclick="javascript:window.location.href='${ctxPath}/indents/showGoods?indentId=${indent.indentId }'">查看商品信息</a></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<ul class="pagination" id="pagination"></ul>
	<script type="text/javascript">
		$(document).ready(function() {
			if($("#pagination")){
				var pagecount =${totalPages} ;
				var currentpage = ${currentPage};
				var pagesize = 10;	
				var counts,pagehtml="";
				if(pagecount%pagesize==0){
					counts = parseInt(pagecount/pagesize);
				}else{
					counts = parseInt(pagecount/pagesize)+1;
				}
				//只有一页内容
				if(pagecount<=pagesize){pagehtml="";}
				//大于一页内容
				if(pagecount>pagesize){
					if(currentpage>1){
						pagehtml+= '<li><a href="${ctxPath}/indents/showIndents?page='+(currentpage-1)+'">上一页</a></li>';
					}
					for(var i=0;i<counts;i++){
						if(i>=(currentpage-3) && i<(currentpage+3)){
							if(i==currentpage-1){
								pagehtml+= '<li class="active"><a href="${ctxPath}/indents/showIndents?page='+(i+1)+'">'+(i+1)+'</a></li>';
							}else{
								pagehtml+= '<li><a href="${ctxPath}/indents/showIndents?page='+(i+1)+'">'+(i+1)+'</a></li>';
							}
							
						}
					}
					if(currentpage<counts){
						pagehtml+= '<li><a href="${ctxPath}/indents/showIndents?page='+(currentpage+1)+'">下一页</a></li>';
					}
				}
				$("#pagination").html(pagehtml);
			}
		});
		
		
</script>
</body>
</html>